#include <bits/stdc++.h>
using namespace std;
int d[100005],v[100005],p[100005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin >> T;
    while(T--)
    {
        int n,m,L,V;
        cin >> n >> m >> L >> V;
        for(int i = 1;i <= n;i++)
        {
            int a;
            cin >> d[i] >> v[i] >> a;
        }
        for(int i = 1;i <= m;i++)
        {
            cin >> p[i];
        }
        int c = 0,minn = 100005;
        for(int i = 1;i <= n;i++)
        {
            if(v[i] > V)
            {
                c++;
                minn = min(minn,d[i]);
            }
        }
        cout << c << " ";
        int k = 0;
        for(int i = 1;i <= m;i++)
        {
            if(p[i] > minn)
            {
                k = i;
            }
        }
        cout << k-1 << endl;
    }
    return 0;
}
